import request from '@/utils/request'

export const getLogsPage = (pageSize = 1, limit = 8, sortOrder = asc) => {
  return request.get('/logs/page', {
    params: {
      pageSize,
      limit,
      sortOrder
    }
  })
}

export const getLogsAll = () => {
  return request.get('/logs/all')
}

export const logsExportIds = (ids) => {
  return request.post(`/excel/logs/export/${ids}`, {
    responseType: 'blob'
  })
    .then(res => {
      console.log(res)
      // fileDownload(res, this.fileName)
    })
}

// export const logsExportIds = (ids) => {
//   return request.get('/excel/logs/export/ids', {
//     params: {
//       ids: 96
//     },
//     responseType: 'blob'
//   })
//     .then((response) => {
//       const url = window.URL.createObjectURL(new Blob([response.data], { type: 'application/vnd.ms-excel' }));
//       const link = document.createElement('a')
//       link.href = url
//       link.setAttribute('download', 'filename.xlsx') // 设置下载文件名
//       document.body.appendChild(link)
//       link.click()
//       document.body.removeChild(link)
//     })
// }


export const exportLogsExcel = () => {
  return request.post('/excel/logs/export', {
    responseType: 'blob'
  })
}

export const deleteLog = (logId) => {
  return request.delete(`/logs/delete/${logId}`)
}

export const updateLogs = (logs) => {
  return request.post('/logs/update', logs)
}
